<?php 
/* 
Template Name: bkack Manager product set
*/
?>
<?php get_header(); 
//$current_user;
global $current_user;
get_currentuserinfo();
?>
<?php 
 if ( !is_user_logged_in() ) 
    {
      ?>

        <div id='content_nano_two' class='clearfix' style='min-height:300px;'>
              <h1 style='color:#000;'>bạn không được phép truy cập trang này </h1>
              <?php wp_die( __( 'Vui lòng đăng nhập hoặc quay lai trang chủ ! ' ) ); ?>
        </div>
         
     <?php 
          
    }//if ( ! current_user_can( 'list_users' ) ) 
elseif (is_user_logged_in() )  
 { 

    if (  ( $current_user->roles[0] == 'author') or ( $current_user->roles[0] == 'contributor') or ( $current_user->roles[0] == 'subscriber') ) 
      {
        ?>

        <div id='content_nano_two' class='clearfix' style='min-height:300px;'>
              <h1 style='color:#000;'>bạn không được phép truy cập trang này </h1>
              <?php wp_die( __( 'Vui lòng  quay lai trang chủ ! ' ) ); ?>
        </div>
         
     <?php 

      }//if ( ( $current_user->roles[0] == 'author') or ( $current_user->roles[0] == 'contributor') or ( $current_user->roles[0] == 'subscriber') ) 
      elseif ( ( $current_user->roles[0] != 'author') or ( $current_user->roles[0] != 'contributor') or ( $current_user->roles[0] != 'subscriber') )
      {

        //echo 'hoang phuc duoc phep';
     ?>

<div id="content_nano_two" class="clearfix">
<?php 
   global $id_prod ;
    $id_prod = array();
   if (isset($_POST['phanquyen'])) 
   {
     $id_prod = $_POST['phanquyen'];  // ID CUA MAY CAN PHAN QUYEN
     $sql_may = "SELECT * FROM wp_may WHERE id_may =".$id_prod;
     $array_may = $wpdb->get_row("SELECT * FROM wp_may WHERE id_may =".$id_prod, ARRAY_A);
     //var_dump($array_may);
   }
?>

<div id='viewmay'>
  <h1 style='float:left;'><?php echo $array_may['name_may'];?></h1>
  <?php if ($array_may['image_may_url'] !=='') 
  {
    ?>
     <img style='height: 100px; width: 100px; float:right;' src="<?php echo get_bloginfo('template_directory').'/upload_may/'.$array_may['image_may_url']; ?>">
    <?php
  }else { ?>
          <img style='height: 100px; width: 100px; float:right;' 
          src="<?php echo get_bloginfo('template_directory').'/images/no_image.gif';?>">
   <?php } ?>
</div><!-- id='viewmay' -->


  <div id="dialog-form-them-quan-tri" >
    <a id="popupClose">x</a>
    <h1>Thêm người quản lí</h1>
        <?php 
     $query_user = "SELECT ID,user_nicename,display_name,user_email,user_registered FROM $wpdb->users" ;
    // WHERE post_type='post'";
    ?>        
               <table class="wp-list-table widefat fixed users" cellspacing="0">
                    <thead>
                     <tr>
                       <th scope="col" id="cb"  style=""> </th>
                       <th scope="col" id="username"  style="width: 100px;"> <span>Tài khoản</span></th>
                       <th scope="col" id="name"   style="width: 150px;"><span>Tên người dùng</span></th>
                       <th scope="col" id="thaotac"style=""></th>
                     </tr>
                    </thead>
                    

                     <tbody id="the-list" data-wp-lists="list:user">
        <?php $rows = $wpdb->get_results($query_user);
             foreach($rows as $post)
             {
         ?>
              <tr id="user-<?php $post->ID; ?>" class="alternate">
                   <th scope="row" class="check-column">
                   </th>
                     <td class="username column-username">
                       <strong><?php echo $post->user_nicename;?></strong>
                    </td>
                    <td class="name column-name"><?php echo $post->display_name;?> </td>
                    <td class="thaotac column-thaotac">
                           <ul style='position: relative;'>
                                <li style='height: 20px;'>
                                     <input type='checkbox' 
                                       nqlisetadmin="<?php echo $post->ID; ?>"
                                       idmaysetadmin="<?php echo $id_prod;?>" 
                                      id="delqli" 
                                      class="addsetqli<?php echo $post->ID; ?>" 
                                      value=' Thêm' style='z-index: 1997;'
                                      name='addsetqli<?php echo $post->ID; ?>'
                                      />
                                     </li>
                           </ul>

                    </td>
                                                   
                </tr><!-- id="user-xyz" class="alternate" -->
        <?php } // end foreach($rows as $post) ?>

         </tbody>
                </table>

  <script type="text/javascript">
    // load_data();// laod lại du lieu khi them nguoi quan tri
        function load_data(ID) 
             {
                                   // var ID = ID;
                                   // alert(ID);
                                      $.ajax({
                                              url:"<?php bloginfo('url');?>/process_load_all_user",
                                              type:"POST",
                                              data: {ID:ID},
                                              dataType:"JSON",
                                              success: function(data_user)
                                              {
                                                alert(data_user);
                                               // debugger;
                                               // return;
                                               var userdata = [];
                                               $.each(data_user, function(key,value)
                                                {
                                                  userdata.push('<li>' +  'ID: ' + value.ID + 'id_may : ' + value.id_may + 'user_login : ' + value.user_login + '<li>');
                                               });
                                               $('<ul/>',{html:userdata.join('')}).appendTo('#content_addqli');
                                               $('.content-2 .wp-list-table.widefat.fixed.users').css('display','none');
                                               //$('.content-2').css({ position: 'absolute', left: '9000000'});
                                               //$('.content-1 .wp-list-table.widefat.fixed.users').css('display','none');
                                               $('#content_addqli').css('width', '960');
                                               $('#content_addqli').css('position', 'relative');
                                               $('#content_addqli').css('z-index', '2003');
                                               $('.content-1 .wp-list-table.widefat.fixed.users').css('z-index', '2001');
                                               $('.content-2').css('min-height', '0');
                                               $('.content div').css({
                                                  position: 'relative',
                                                  overflow: 'none'
                                                });

                                               }
                                        });

                                    
                                  }

                            
               jQuery(document).ready(function()
                    {

                                    $("td input[name^='addsetqli']").click(function() {
                                    var  nqlisetadmin = $(this).attr("nqlisetadmin");
                                    var idmaysetadmin = $(this).attr("idmaysetadmin");
                                    $.ajax({
                                            url:"<?php bloginfo('url');?>/prosessing_them_set_admin_qlimay",
                                              type:"POST",
                                              data: {nqlisetadmin:nqlisetadmin,idmaysetadmin:idmaysetadmin},
                                              success: function(data)
                                              {
                                                //alert(data);
                                                $('#content_addqli').html(data);
                                                window.disablePopupphuc();
                                                //load_data(nqlisetadmin);
                                                //debugger;
                                              }
                                        });
                                    });
                                      
                                  })
                            
                </script>     
</div><!-- id="dialog-form-them-quan-tri" title="Chọn thêm người phân quyền" -->



<div style='margin:20px;'></div>

<div class="clearfix"><!-- id="container" style="min-height: 606px;" -->
      <section class="tabs" style="min-height: 606px;">

<?php 

 if (  ( $current_user->roles[0] == 'author') or ( $current_user->roles[0] == 'contributor') or ( $current_user->roles[0] == 'subscriber') or ( $current_user->roles[0] == 'editor') ) 
      {

        ?>
        <!--
        <div id='content_nano_two' class='clearfix' style='min-height:300px;'>
              <h1 style='color:#000;'>bạn không được phép truy cập trang này </h1>
              <?php //wp_die( __( 'Vui lòng  quay lai trang chủ ! ' ) ); ?>
        </div>
         -->
     <?php 

      }//if ( ( $current_user->roles[0] == 'author') or ( $current_user->roles[0] == 'contributor') or ( $current_user->roles[0] == 'subscriber') ) 
      elseif ( ( $current_user->roles[0] != 'author') or ( $current_user->roles[0] != 'contributor') or ( $current_user->roles[0] != 'subscriber') or ( $current_user->roles[0] != 'editor')  )
      {

        //echo 'hoang phuc duoc phep';
  
     ?>


        <input id="tab-1" type="radio" name="radio-set" class="tab-selector-1" checked="checked" />
        <label for="tab-1" class="tab-label-1">Người quản lí </label>

    <?php 
    } // elseif ( ( $current_user->roles[0] != 'author') or ( $current_user->roles[0] != 'contributor') or ( $current_user->roles[0] != 'subscriber') )
    ?>



    
        <input id="tab-2" type="radio" name="radio-set" class="tab-selector-2" <?php if ( $current_user->roles[0] == 'editor') { ?> checked="checked"  <?php } ?> />
        <label for="tab-2" class="tab-label-2">Người dùng</label>
    
        <div class="clear-shadow"></div>
        
        <div class="content" style="min-height: 606px;" >

 <?php 

     if (  ( $current_user->roles[0] == 'author') or ( $current_user->roles[0] == 'contributor') or ( $current_user->roles[0] == 'subscriber') or ( $current_user->roles[0] == 'editor') ) 
          {

            ?>
            <!--

            <div id='content_nano_two' class='clearfix' style='min-height:300px;'>
                  <h1 style='color:#000;'>bạn không được phép truy cập trang này </h1>
                  <?php //wp_die( __( 'Vui lòng  quay lai trang chủ ! ' ) ); ?>
            </div>
            -->
         <?php 

          }//if ( ( $current_user->roles[0] == 'author') or ( $current_user->roles[0] == 'contributor') or ( $current_user->roles[0] == 'subscriber') ) 
          elseif ( ( $current_user->roles[0] != 'author') or ( $current_user->roles[0] != 'contributor') or ( $current_user->roles[0] != 'subscriber') or ( $current_user->roles[0] != 'editor')  )
          {

            //echo 'hoang phuc duoc phep';
      
         ?>

            <div class="content-1" style="min-height: 606px;">
                <h2>Người quản lí</h2>
                <span class='buttonspan'>
                  <button class="hoanghalangqli" style="padding: 4px;margin-bottom: 5px;color: #555;position: relative;z-index: 1996;float: left;left: 0px;">Thêm người quản lí</button>
                </span>

                 <span id='content_addqli'>
                  <!-- noi dung viet o day -->
                   <p>
                          
                    <?php 
                      $sql = "SELECT * FROM wp_user_wp_may
                                                                      INNER JOIN wp_users
                                                                                  ON wp_users.ID = wp_user_wp_may.ID
                                                                                  WHERE id_may =".$id_prod."";  
                                              
                                            $row = $wpdb->get_results($sql);
                                                            
                                                              ?> 
                                                             <table class="wp-list-table widefat fixed users" cellspacing="0">
                                                                  <thead>
                                                                   <tr>
                                                                     <th scope="col" id="cb"  style=""> </th>
                                                                     <th scope="col" id="username"  style=""> <span>Tài khoản</span></th>
                                                                     <th scope="col" id="name"  style=""><span>Tên người dùng</span></th>
                                                                     <th scope="col" id="xoang"style=""></th>
                                                                   </tr>
                                                                  </thead>
                                                                   <tbody id="the-list" data-wp-lists="list:user">
                                                      <?php 
                                                        foreach($row as $key=>$value)
                                                       {
                                                        //var_dump($value);//break;
                                                       ?>
                                                            <tr id="user-<?php echo $value->ID; ?>" class="alternate">
                                                                 <th scope="row" class="check-column">
                                                                   <label class="screen-reader-text" for="cb-select-1"></label>
                                                                 </th>
                                                                   <td class="username column-username">
                                                                     <strong><?php echo $value->user_login;?></strong>
                                                                  </td>
                                                                  <td class="name column-name"><?php echo $value->display_name;?></td>
                                                                  <td class="xoang column-xoang">
                                                                    <ul style='position: relative;'>
                                                                      <li style='height: 20px;'>
                                                                        <input type='button' 
                                                                        nguoiquanli="<?php echo $value->ID; ?>"
                                                                        idmay="<?php echo $id_prod;?>" 
                                                                        id="delqli" 
                                                                        class="delqli<?php echo $value->ID; ?>" 
                                                                        value=' xóa' style='z-index: 1986;'
                                                                        name='delqli<?php echo $value->ID; ?>'
                                                                        />
                                                                      </li>
                                                                    </ul>
                                                                    <!-- onclick="if (!confirm("Bạn không xóa máy này ? chọn Click OK . Nếu bạn muốn xóa chọn HỦY")) return false;"  -->    
                                                                  </td>
                                                            </tr><!-- id="user-xyz" class="alternate" -->
                                                      <?php             
                                                            }// foreach($row as $key=>$value)
                                                        ?>

                                                        
                                                             </tbody>
                                                                    </table>

                                    <!-- </div><!-- id='moidauload' -->
                                        
                            </p>
                 </span><!--content_addqli -->
               

              <div id="backgroundPopupqli"></div><!-- id="backgroundPopup" --> 
               
                 <script type="text/javascript">
                            
                               jQuery(document).ready(function(){

                                    $("td input[name^='delqli']").click(function() {
                                    var nguoiquanli = $(this).attr("nguoiquanli");
                                    var idmay = $(this).attr("idmay");
                                   
                                    $.ajax({
                                            url:"<?php bloginfo('url');?>/prosessing_xoa_may",
                                              type:"POST",
                                              data: {nguoiquanli:nguoiquanli,idmay:idmay},
                                              success: function(data)
                                              {
                                                $('#content_addqli').html(data);
                                                $('#content_addqli').show();
                                                $('#content_addqli').css('z-index','20001');
                                                //$('.wp-list-table.widefat.fixed.users').css('display','none');
                                                //$('.wp-list-table.widefat.fixed.users').css('width','800px');
                                               }
                                        });
                                    });
                                      
                                  })
                            
                </script>

      <script type="text/javascript">
                  /***************************/
                  //@Author: PHUC IT
                  //@website: www.maybanhang.net
                  //@email: phuca4@gmail.com
                  /***************************/
                           var popupphuc = 0;

                            function loadPopupphuc(){
                              if(popupphuc==0){
                                $("#backgroundPopupqli").css({
                                  "opacity": "0.7"
                                });
                                $("#backgroundPopupqli").fadeIn("slow");
                                $("#dialog-form-them-quan-tri").fadeIn("slow");
                                popupphuc = 1;
                              }
                            }

                            function disablePopupphuc(){
                              if(popupphuc==1){
                                $("#backgroundPopupqli").fadeOut("slow");
                                $("#dialog-form-them-quan-tri").fadeOut("slow");
                                popupphuc = 0;
                              }
                            }

                            
                        

                           //load_data_set_nguoidung_cua_admin(setnguoidung,idmaysetnguoidung);
                         function load_data_set_nguoidung_cua_admin(idmayngdung) 
                                  {
                                    
                                    var idmayngdung = idmayngdung;
                                    alert(idmayngdung);
                                      $.ajax({
                                              url:"<?php bloginfo('url');?>/process_load_user_nguoi_dung_la_admin",
                                              type:"POST",
                                              data: {idmayngdung:idmayngdung},
                                              dataType:"JSON",
                                              success: function(data_user_nd)
                                              {
                                                alert(data_user_nd);
                                               // debugger;
                                               // return;
                                               var setnguoidunglaadmin = [];
                                               $.each(data_user_nd, function(key,value)
                                                {
                                                  setnguoidunglaadmin.push('<li>' + key + 'ID: ' + value.ID + 'id_may : ' + value.id_may + 'user_login : ' + value.user_login + '<li>');
                                               });
                                               $('<ul/>',{html:setnguoidunglaadmin.join('')}).appendTo('#phanquyennguoidungadmin');
                                               $('.content-2 .wp-list-table.widefat.fixed.users').css('display','none');
                                               $('.content-2').css({ position: 'absolute', left: '9000000'});
                                               $('.content-1 .wp-list-table.widefat.fixed.users').css('display','none');
                                               $('#content_addqli').css('width', '960');
                                               $('#content_addqli').css('position', 'relative');
                                               $('#content_addqli').css('z-index', '2003');
                                               $('.content-1 .wp-list-table.widefat.fixed.users').css('z-index', '2001');
                                               $('.content-2').css('min-height', '0');
                                               $('.content div').css({
                                                  position: 'relative',
                                                  overflow: 'none'
                                                });

                                               }
                                        });
                                  }


                            //centering popup
                            function centerPopuppphuc(){
                              //request data for centering
                              var windowWidth = document.documentElement.clientWidth;
                              var windowHeight = document.documentElement.clientHeight;
                              var popupHeight = $("#dialog-form-them-quan-tri").height();
                              var popupWidth = $("#dialog-form-them-quan-tri").width();
                              

                              $("#dialog-form-them-quan-tri").css({
                                "position": "absolute",
                                "top": windowHeight/2-popupHeight/2,
                                "left": windowWidth/2-popupWidth/2
                              });
                              
                              $("#backgroundPopupqli").css({
                                "height": windowHeight
                              });
                            }

                            // jQuery(document).ready(function()
                            jQuery(document).ready(function(){
                              
                               $(".hoanghalangqli").click(function(){
                                //centering with css
                                centerPopuppphuc();
                                //load popup
                                loadPopupphuc();
                              });
                                    
                              //CLOSING POPUP
                              //Click the x event!
                              $("#popupClose").click(function(){
                                disablePopupphuc();
                              });
                              //Click out event!
                              $("#backgroundPopupqli").click(function(){
                                disablePopupphuc();
                              });
                              //Press Escape event!
                              $(document).keypress(function(e){
                                if(e.keyCode==27 && popupphuc==1){
                                  disablePopupphuc();
                                }
                              });

                            });
                            
                </script>

            </div><!-- class="content-1" -->
     <?php 
    } // elseif ( ( $current_user->roles[0] != 'author') or ( $current_user->roles[0] != 'contributor') or ( $current_user->roles[0] != 'subscriber') )
    ?>

    <?php 
    if (( $current_user->roles[0] == 'administrator')) 
    {
      ?> 
     
         <div class="content-2" style="min-height: 606px;">
                <h2>Người dùng</h2>
                <?php  echo ' Admintrator';?>
                 <button id="Admintrator" style="padding: 4px;margin-bottom:5px;color: #555;" role="button">Thêm người dùng</button>
                 
                <span id='phanquyennguoidungadmin'>
                  <?php
                          $sql = "SELECT wp_user_wp_may.ID,wp_user_wp_may.id_may,wp_users.ID,wp_users.user_login
                            FROM wp_user_wp_may
                            INNER JOIN wp_users
                            ON wp_users.ID = wp_user_wp_may.ID
                            WHERE wp_user_wp_may.id_may = ".$id_prod ;
                                                //echo $sql ;
                                                 $row = $wpdb->get_results($sql);
                                                 //var_dump($row );
                                                ?> 
                                               <table class="wp-list-table widefat fixed users" cellspacing="0">
                                                    <thead>
                                                     <tr>
                                                       <th scope="col" id="cb"  style=""> </th>
                                                       <th scope="col" id="username"  style=""> <span>Tài khoản</span></th>
                                                       <th scope="col" id="name"  style=""><span>Tên người dùng</span></th>
                                                       <th scope="col" id="email"style=""></th>
                                                     </tr>
                                                    </thead>
                                                     <tbody id="the-list" data-wp-lists="list:user">
                                        <?php 
                                          foreach($row as $key=>$value)
                                         {
                                          //var_dump($value);//break;
                                         ?>
                                              <tr id="user-<?php echo $value->ID; ?>" class="alternate">
                                                   <th scope="row" class="check-column">
                                                     <label class="screen-reader-text" for="cb-select-1"></label>
                                                   </th>
                                                     <td class="username column-username">
                                                       <strong><?php echo $value->user_login;?></strong>
                                                    </td>
                                                    <td class="name column-name"><?php echo $value->display_name;?></td>
                                                    <td class="email column-email">
                                                       
                                                       <ul style='position: relative;'>
                                                        <li style='height: 30px;'>
                                                        <input type="button" 
                                                         nguoidung="<?php echo $value->ID; ?>" 
                                                         idmay="<?php echo $id_prod;?>"
                                                         name="delng<?php echo $value->ID; ?>" 
                                                         id="delnguoidung" 
                                                         class="delnguoidung"
                                                         value="Xóa"
                                                         />
                                                       </li></ul>
                                                         
                                                    </td>
                                                                                         
                                                      </tr><!-- id="user-xyz" class="alternate" -->
  
                                        <?php             
                                              }// foreach($row as $key=>$value)
                                          ?>

                                   </tbody>
                             </table>
          </span><!-- id='phanquyennguoidungadmin' -->

      <div id="backgroundPopup"></div><!-- id="backgroundPopup" --> 

                 <script type="text/javascript">
                               jQuery(document).ready(function(){
                                    $("td input[name^='delng']").click(function() {
                                    var nguoidung = $(this).attr("nguoidung");
                                    var idmay = $(this).attr("idmay");
                                    $.ajax({
                                            url:"<?php bloginfo('url');?>/prosessing_admin_delngdung",
                                              type:"POST",
                                              data: {nguoidung:nguoidung,idmay:idmay},
                                              success: function(data)
                                              {
                                                //alert(data);
                                                $('#phanquyennguoidungadmin').html(data);
                                               }
                                        });
                                    });
                                      
                                  })
                             
                 </script>


                  <script type="text/javascript">
                  /***************************/
                  //@Author: PHUC IT
                  //@website: www.maybanhang.net
                  //@email: phuca4@gmail.com
                  /***************************/
                           var popupStatus = 0;

                            function loadPopup(){
                              if(popupStatus==0){
                                $("#backgroundPopup").css({
                                  "opacity": "0.7"
                                });
                                $("#backgroundPopup").fadeIn("slow");
                                $("#dialog-form-them-nguoi-dung").fadeIn("slow");
                                popupStatus = 1;
                              }
                            }

                            function disablePopup(){
                              if(popupStatus==1){
                                $("#backgroundPopup").fadeOut("slow");
                                $("#dialog-form-them-nguoi-dung").fadeOut("slow");
                                popupStatus = 0;
                              }
                            }

                            //centering popup
                            function centerPopup(){
                              //request data for centering
                              var windowWidth = document.documentElement.clientWidth;
                              var windowHeight = document.documentElement.clientHeight;
                              var popupHeight = $("#dialog-form-them-nguoi-dung").height();
                              var popupWidth = $("#dialog-form-them-nguoi-dung").width();
                              

                              $("#dialog-form-them-nguoi-dung").css({
                                "position": "absolute",
                                "top": windowHeight/2-popupHeight/2,
                                "left": windowWidth/2-popupWidth/2,
                              });
                              
                              $("#backgroundPopup").css({
                                "height": windowHeight
                              });
                            }

                            // jQuery(document).ready(function()
               jQuery(document).ready(function(){
                              
                              $("#adduserngdung").click(function(){
                                //centering with css
                                centerPopup();
                                //load popup
                                loadPopup();
                              });
                                    
                              //CLOSING POPUP
                              //Click the x event!
                              jQuery("#popupCloseng").click(function(){
                                disablePopup();
                              });
                              //Click out event!
                              $("#backgroundPopup").click(function(){
                                disablePopup();
                              });
                              //Press Escape event!
                              $(document).keypress(function(e){
                                if(e.keyCode==27 && popupStatus==1){
                                  disablePopup();
                                }
                              });

                            });
                            
                </script>
                </p>
                
            </div><!-- class="content-2" -->
      <?php
    } //end admin

    if (( $current_user->roles[0] == 'editor')) 
    {

      ?>
        <div class="content-2" style="min-height: 606px;">
                <h2>Người dùng</h2>
                 <button id="adduserngdung" style="padding: 4px;margin-bottom:5px;color: #555;" role="button">Thêm người dùng</button>
          <span id ='phanquyenguoidungbinhthuong'>
                 <?php //echo 'dang la nguoi quan li'; ?>
                           <?php 
                            
                            $sql = "SELECT * FROM wp_user_wp_may
                                                        INNER JOIN wp_users
                                                                    ON wp_users.ID = wp_user_wp_may.ID
                                                                    WHERE id_may =".$id_prod;  
                          
                             $row = $wpdb->get_results($sql);
                                                
                                                ?> 

                

                                               <table class="wp-list-table widefat fixed users" cellspacing="0">
                                                    <thead>
                                                     <tr>
                                                       <th scope="col" id="cb"  style=""> </th>
                                                       <th scope="col" id="username"  style=""> <span>Tài khoản</span></th>
                                                       <th scope="col" id="name"  style=""><span>Tên người dùng</span></th>
                                                       <th scope="col" id="email"style=""></th>
                                                     </tr>
                                                    </thead>
                                                     <tbody id="the-list" data-wp-lists="list:user">
                                        <?php 
                                          foreach($row as $key=>$value)
                                         {
                                          //var_dump($value);//break;
                                         ?>
                                              <tr id="user-<?php echo $value->ID; ?>" class="alternate">
                                                   <th scope="row" class="check-column">
                                                     <label class="screen-reader-text" for="cb-select-1"></label>
                                                   </th>
                                                     <td class="username column-username">
                                                       <strong><?php echo $value->user_login;?></strong>
                                                    </td>
                                                    <td class="name column-name"><?php echo $value->display_name;?></td>
                                                    <td class="email column-email">
                                                       
                                                       <ul style='position: relative;'>
                                                        <li style='height: 30px;'>
                                                        <input type="button" 
                                                         nguoidung="<?php echo $value->ID; ?>" 
                                                         idmay="<?php echo $id_prod;?>"
                                                         name="delng<?php echo $value->ID; ?>" 
                                                         id="delnguoidung" 
                                                         class="delnguoidung"
                                                         value="Xóa"
                                                      
                                                         />
                                                       </li></ul>
                                                         <!-- onclick="return confirm('Bạn không xóa máy này ?')"; -->
                                                    </td>
                                                                                         
                                                      </tr><!-- id="user-xyz" class="alternate" -->
                                        <?php             
                                              }// foreach($row as $key=>$value)
                                          ?>

                                               </tbody>
                                                      </table>    
        </span><!-- id ='phanquyenguoidungbinhthuong' -->                  
<div id="backgroundPopup"></div><!-- id="backgroundPopup" --> 
                 <script type="text/javascript">

                     function load_set_user_ng(idmay) 
                                  {
                                    
                                    var idmay = idmay;
                                   
                                      $.ajax({
                                              url:"<?php bloginfo('url');?>/load_prosessing_ngdung_notadmin",
                                              type:"POST",
                                              data: {idmay:idmay},
                                              dataType:"JSON",
                                              success: function(data_user_nd)
                                              {
                                                //alert(data_user_nd);
                                               // debugger;
                                               // return;
                                               var xoangdung = [];
                                               $.each(data_user_nd, function(key,value)
                                                {
                                                  xoangdung.push('<li>' +  'ID: ' + value.ID + 'id_may : ' + value.id_may + 'user_login : ' + value.user_login + '<li>');
                                               });
                                               $('<ul/>',{html:xoangdung.join('')}).appendTo('#content_add_nguoi_editor');
                                               $('.content-2 .wp-list-table.widefat.fixed.users').css('display','none');
                                               $('.content-2').css({ position: 'absolute', left: '9000000'});
                                               $('.content-1 .wp-list-table.widefat.fixed.users').css('display','none');
                                               $('#content_addqli').css('width', '960');
                                               $('#content_addqli').css('position', 'relative');
                                               $('#content_addqli').css('z-index', '2003');
                                               $('.content-1 .wp-list-table.widefat.fixed.users').css('z-index', '2001');
                                               $('.content-2').css('min-height', '0');
                                               $('.content div').css({
                                                  position: 'relative',
                                                  overflow: 'none'
                                                });

                                               }
                                        });
                             
                                  }

                       
                               jQuery(document).ready(function(){

                                    $("td input[name^='delng']").click(function() {
                                    var idxoa = $(this).attr("nguoidung");
                                    var idmay = $(this).attr("idmay");
                                    //alert(nguoidung);
                                    //alert(idmay);
                                    //return;
                                    $.ajax({
                                            url:"<?php bloginfo('url');?>/prosessing_ngdung_notadmin",
                                              type:"POST",
                                              data: {idxoa:idxoa,idmay:idmay},
                                              success: function(data)
                                              {
                                                alert(data);
                                                //load_set_user_ng(idmay);
                                                 $('#phanquyenguoidungbinhthuong').html(data);
                                              }
                                        });
                                    });
                                      
                                  })
                             
                 </script>


                  <script type="text/javascript">
                  /***************************/
                  //@Author: PHUC IT
                  //@website: www.maybanhang.net
                  //@email: phuca4@gmail.com
                  /***************************/
                           var popupStatus = 0;

                            function loadPopup(){
                              if(popupStatus==0){
                                $("#backgroundPopup").css({
                                  "opacity": "0.7"
                                });
                                $("#backgroundPopup").fadeIn("slow");
                                $("#dialog-form-them-nguoi-dung").fadeIn("slow");
                                popupStatus = 1;
                              }
                            }

                            function disablePopup(){
                              if(popupStatus==1){
                                $("#backgroundPopup").fadeOut("slow");
                                $("#dialog-form-them-nguoi-dung").fadeOut("slow");
                                popupStatus = 0;
                              }
                            }

                            //centering popup
                            function centerPopup(){
                              //request data for centering
                              var windowWidth = document.documentElement.clientWidth;
                              var windowHeight = document.documentElement.clientHeight;
                              var popupHeight = $("#dialog-form-them-nguoi-dung").height();
                              var popupWidth = $("#dialog-form-them-nguoi-dung").width();
                              

                              $("#dialog-form-them-nguoi-dung").css({
                                "position": "absolute",
                                "top": windowHeight/2-popupHeight/2,
                                "left": windowWidth/2-popupWidth/2,
                              });
                              
                              $("#backgroundPopup").css({
                                "height": windowHeight
                              });
                            }

                            // jQuery(document).ready(function()
               jQuery(document).ready(function(){
                              
                              $("#adduserngdung").click(function(){
                                //centering with css
                                centerPopup();
                                //load popup
                                loadPopup();
                              });
                                    
                              //CLOSING POPUP
                              //Click the x event!
                              jQuery("#popupCloseng").click(function(){
                                disablePopup();
                              });
                              //Click out event!
                              $("#backgroundPopup").click(function(){
                                disablePopup();
                              });
                              //Press Escape event!
                              $(document).keypress(function(e){
                                if(e.keyCode==27 && popupStatus==1){
                                  disablePopup();
                                }
                              });

                            });
                            
                </script>
                </p>
                
            </div><!-- class="content-2" -->

      <?php
    } // end editor
    ?>
           
            

        </div><!-- End div.content -->
    </section>
</div> <!-- id="container" -->


<div id="dialog-form-them-nguoi-dung" title="Thêm người dùng" style="min-height: 90%;" >
  <a id="popupCloseng">x</a>
  <h1>Thêm người dùng</h1>

         <?php 
         $query_user = "SELECT ID,user_nicename,display_name,user_email,user_registered FROM $wpdb->users" ;
        // WHERE post_type='post'";
        ?>         
                 
                   <table class="wp-list-table widefat fixed users" cellspacing="0">
                        <thead>
                         <tr>
                           <th scope="col" id="cb"  style=""> </th>
                           <th scope="col" id="username"  style="width: 100px;"> <span>Tài khoản</span></th>
                           <th scope="col" id="name"  style="width: 150px;"><span>Tên người dùng</span></th>
                           <th scope="col" id="thaotac"style=""></th>
                         </tr>
                        </thead>
                        

                         <tbody id="the-list" data-wp-lists="list:user">
            <?php $rows = $wpdb->get_results($query_user);
                 foreach($rows as $post)
                 {
             ?>
                  <tr id="user-<?php $post->ID; ?>" class="alternate">
                       <th scope="row" class="check-column">
                       </th>
                         <td class="username column-username">
                           <strong><?php echo $post->user_nicename;?></strong>
                        </td>
                        <td class="name column-name"><?php echo $post->display_name;?> </td>
                        <td class="thaotac column-thaotac">
                               <ul style='position: relative;'>
                                    <li style='height: 20px;'>
                                         <input type='checkbox' 
                                           setnguoidung="<?php echo $post->ID; ?>"
                                           idmaysetnguoidung="<?php echo $id_prod;?>" 
                                          id="setqli" 
                                          class="addsetngdung<?php echo $post->ID; ?>" 
                                          value=' Thêm' style='z-index: 1997;'
                                          name='addsetngdung<?php echo $post->ID; ?>'
                                          />
                                         </li>
                               </ul>

                        </td>
                                                       
                    </tr><!-- id="user-xyz" class="alternate" -->
            <?php } // end foreach($rows as $post) ?>

             </tbody>
                    </table>

      <script type="text/javascript">

      //load_data_set_nguoidung(setnguoidung,idmaysetnguoidung);
                         function load_data_set_nguoidung(idmay) 
                                  {
                                   // debugger;
                                    var idmay = idmay;
                                    //alert(idmay);
                                  

                                      $.ajax({
                                              url:"<?php bloginfo('url');?>/process_load_user_nguoi_dung",
                                              type:"POST",
                                              data: {idmay:idmay},
                                              dataType:"JSON",
                                              success: function(data_user_nd)
                                              {
                                               // alert(data_user_nd);
                                               // debugger;
                                               // return;
                                               var setuserngd = [];
                                               $.each(data_user_nd, function(key,value)
                                                {
                                                  setuserngd.push('<li>' + 'ID: ' + value.ID + ' id_may : ' + value.id_may + 'user_login : ' + value.user_login + '<li>');
                                               });
                                               $('<ul/>',{html:setuserngd.join('')}).appendTo('#content_add_nguoi_editor');
                                               $('.content-2 .wp-list-table.widefat.fixed.users').css('display','none');
                                               $('.content-2').css({ position: 'absolute', left: '9000000'});
                                               $('.content-1 .wp-list-table.widefat.fixed.users').css('display','none');
                                               $('#content_addqli').css('width', '960');
                                               $('#content_addqli').css('position', 'relative');
                                               $('#content_addqli').css('z-index', '2003');
                                               $('.content-1 .wp-list-table.widefat.fixed.users').css('z-index', '2001');
                                               $('.content-2').css('min-height', '0');
                                               $('.content div').css({
                                                  position: 'relative',
                                                  overflow: 'none'
                                                });

                                               }
                                        });
                                  }
                                
         jQuery(document).ready(function(){

                                        $("td input[name^='addsetngdung']").click(function() {
                                        var  setnguoidung = $(this).attr("setnguoidung");
                                        var idmaysetnguoidung = $(this).attr("idmaysetnguoidung");
                                     
                                      //  alert('setnguoidung');
                                      //  alert(setnguoidung);
                                      //  alert('idmaysetnguoidung');
                                      //  alert(idmaysetnguoidung);
                                        //return;

                                        $.ajax({
                                                url:"<?php bloginfo('url');?>/prosessing_them_set_nguoi_qlimay",
                                                  type:"POST",
                                                  data: {setnguoidung:setnguoidung,idmaysetnguoidung:idmaysetnguoidung},
                                                  success: function(data){
                                                    alert(data);
                                                  $('#sent').show();
                                                  $('#phuc').html(data);
                                                  $('#phuc').show()
                                                  $('#moidauload').css('display','none');
                                                   load_data_set_nguoidung(idmaysetnguoidung);
                                                  // debugger;
                                                   window.disablePopup();
                                                    // load lai du lieu voi tat ca cac may voi id user truyen vào 
                                                   

                                                                  }
                                            });
                                      
                                        });
                                          
                                      })
                                
                    </script>     
          
  
    </div><!-- id="dialog-form-them-nguoi-dung"-->
           

</div><!-- id="content_nano_two" -->

<?php 
} //  elseif ( ( $current_user->roles[0] != 'author') or ( $current_user->roles[0] != 'contributor') or ( $current_user->roles[0] != 'subscriber') )
} //elseif ( ! current_user_can( 'list_users' ) )  
?>
    
<?php get_footer(); ?>